package cn.com.code.hwjs;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Scanner;

/**
 * HJ36 字符串加密 不是很理解
 * https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3?tpId=37&tqId=21259&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
 *
 * @author zhengpei
 * @date 2022/4/27
 */
public class Hwjs36 {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      String s1 = sc.nextLine().toUpperCase();
      String s2 = sc.nextLine();
      char[] chars1 = s1.toCharArray();
      char[] chars2 = s2.toCharArray();
      LinkedHashSet<Character> set = new LinkedHashSet();
      for (int i = 0; i < chars1.length; i++) {
        set.add(chars1[i]);
      }
      int k = 0;
      while (set.size() < 26) {
        char a = (char) ('A' + k);
        set.add(a);
        k++;
      }
      ArrayList<Character> list = new ArrayList<>(set);
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < chars2.length; i++) {
        if (chars2[i] == ' ') {
          sb.append(chars2[i]);
        } else if (chars2[i] < 'a') {
          int n = (int) (chars2[i] - 'A');
          char c = list.get(n);
          sb.append(c);
        } else {
          int n = (int) (chars2[i] - 'a');
          char c = (char) (list.get(n) + 'a' - 'A');
          sb.append(c);
        }

      }

      System.out.println(sb.toString());
    }
  }

}
